package com.chat.view;

import java.util.Objects;

/*
  存放聊天listview的数据
 */
public class ChatListData {
    String nickname;//聊天用户的昵称
    String content;//聊天内容
    String id;//聊天用户的id
    String type;//消息类型（1是文本，2是图片，3是文件）
    String filename;//文件名
    String time;//时间
    byte[] file;//存储文件的二进制流
    String fileaddress;//本地文件的路径

    public ChatListData(String nickname, String content,String id,String type,String time) {
        this.nickname = nickname;
        if(Objects.equals(type, "1"))
        this.content = content;
        else if(Objects.equals(type, "2")){
              this.filename=content;
        }
        this.id=id;
        this.type=type;
        this.time=time;
    }
    public ChatListData(String nickname,String filename,byte[] file,String id,String time,String type){
          this.nickname=nickname;
          this.filename=filename;
          this.id=id;
          this.file=file;
          this.type=type;
          this.time=time;
    }
    public ChatListData(String nickname,String fileaddress,String filename,String id,String time,String type){
         this.nickname=nickname;
         this.fileaddress=fileaddress;
         this.time=time;
         this.type=type;
         this.id=id;
         this.filename=filename;
    }


    public ChatListData(){

    }
    public byte[] getFile() {
        return file;
    }

    public void setFile(byte[] file) {
        this.file = file;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ChatListData that = (ChatListData) o;
        return Objects.equals(nickname, that.nickname) && Objects.equals(content, that.content);
    }

    @Override
    public int hashCode() {
        return Objects.hash(nickname, content);
    }

    @Override
    public String toString() {
        return "ChatListData{" +
                "nickname='" + nickname + '\'' +
                ", content='" + content + '\'' +
                '}';
    }
}
